package monitor

import (
	"fmt"
	corev1 "gluenet/internal/agent/api/core/v1"
	"gluenet/internal/agent/depend"
	dockermonitor "gluenet/internal/agent/monitor/docker"
	k8smonitor "gluenet/internal/agent/monitor/k8s"
	"gluenet/internal/agent/monitor/option"
)

func init() {
	depend.Provide(NewBooterFormConfig)
}

type Interface interface {
	Init(opts *option.MonitorOptions) error

	Close() error
}

// 启动监控组件
func NewBooterFormConfig(platformInfo *corev1.PlatformInfo) (booter Interface, err error) {
	switch {
	case platformInfo.Platform == `kubernetes`:
		booter = depend.Produce[*k8smonitor.K8sMonitorBooter]()
	case platformInfo.Platform == `gluenets` && platformInfo.Role == `normal`:
		booter = depend.Produce[*dockermonitor.DockerMonitorBooter]()
	default:
		err = fmt.Errorf("invalid platform or role")
	}

	return
}
